# list 序列
## 创建
###使用[]
a = [1,2,3,'hh']
b = []
###使用list()
aa = list()
bb = list(range(10))
c = list("abc,hello")


###推导式
d = [x*2 for x in range(5)]
e = [x*2 for x in range(100) if x % 9 == 0]
print(d,e)


# 对象是否修改
a = [1, 3]
b = [4, 5]
print(a,id(a))
a.extend(b)
print(a,id(a))
c1 = a * 3
print(c1,id(c1))
a = a + b
print(a, id(a))

# 删除
## 索引
print(a,b)
del a[0]
del b[1:2:1]
del b[:]
print(a,b)
a.pop()
a.pop(-2)
print(a,b)
a.pop(0)
print(a,b)
## 按值
a.remove(4)
print(a, b)
b.clear()
print(a, b)

## 搜索
cc = [3, 22, 2, 4, 3]
print('3 in cc:', cc.index(3, 0, 3))
print('3 in cc:', cc.index(3, 1, 5))
print('3 in cc:', cc.index(3, 0, 1))
print(cc[0:1]) ## arr[start:end], 同样也不包括end
## -> index(val, start, end),但不包含end
# read and stat
print(c1)
print(c1.index(3))



# 序列解包
x, y, z = (10, 2, 3)
x1, y1, z1 = [10, 2, 34]
e, f, g = 10, 2, 33
print(x, y, z)
print(x1, y1, z1)
print(e, f, g)
[xx, yy, zz] = [11, 12, 13]
(ee, ff, gg) = (11, 12, 13)
[ee1, ff1, gg1] = (11, 12, 113)
print(xx, yy, zz)
print(ee, ff, gg)
print(ee1, ff1, gg1)
## 字典默认解包的是keys
aaa = {"name": "tonywu", "age": 42}
for i in aaa:
    print(i)
A, B = aaa
print(A, B)